<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - Fine-SE | 智能代码项目工作量评估系统</title>
    {% load static %}
    <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
    <style>
        :root {
            --primary-color: #3498db;
            --secondary-color: #2ecc71;
            --dark-color: #34495e;
            --light-color: #ecf0f1;
        }

        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            min-height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .login-container {
            width: 100%;
            max-width: 400px;
            padding: 30px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
            text-align: center; /* 使内部内容居中 */
        }

        .login-header {
            margin-bottom: 30px;
        }

        .login-header h2 {
            color: var(--dark-color);
            font-weight: 600;
            margin-bottom: 10px;
        }

        .login-header p {
            color: #7f8c8d;
            font-size: 14px;
            margin-bottom: 20px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            align-items: center; /* 使表单组内容居中 */
            margin-bottom: 15px;
            width: 100%;
        }

        .form-control {
            height: 45px;
            border-radius: 5px;
            border: 1px solid #ddd;
            padding-left: 15px;
            width: 100%;
            max-width: 300px; /* 限制输入框最大宽度 */
            box-sizing: border-box; /* 确保padding不影响宽度 */
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
        }

        .btn-login {
            background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
            border: none;
            color: white;
            height: 45px;
            border-radius: 5px;
            font-weight: 500;
            width: 100%;
            max-width: 300px; /* 与输入框保持一致 */
            transition: all 0.3s;
            margin-top: 10px;
        }

        .btn-login:hover {
            background: linear-gradient(45deg, #2980b9, #27ae60);
            transform: translateY(-2px);
        }

        .form-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 20px;
            font-size: 14px;
            width: 100%;
            max-width: 300px; /* 与输入框保持一致 */
            margin-left: auto;
            margin-right: auto;
        }

        .form-footer a {
            color: var(--primary-color);
            text-decoration: none;
        }

        .remember-me {
            display: flex;
            align-items: center;
        }

        .remember-me input {
            margin-right: 5px;
        }

        .alert-danger {
            max-width: 300px;
            margin: 0 auto 15px;
            text-align: left;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-header">
            <h2><i class="fa fa-code"></i> 智能代码评估</h2>
            <p>请输入您的账号信息登录系统</p>
        </div>

        <form method="post" action="/login/">
            {% csrf_token %}
            {% if error_message %}
            <div class="alert alert-danger">{{ error_message }}</div>
            {% endif %}

            <div class="form-group">
                <input type="text" class="form-control" name="username" placeholder="账号" required autofocus>
            </div>

            <div class="form-group">
                <input type="password" class="form-control" name="password" placeholder="密码" required>
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-login">登 录</button>
            </div>

            <div class="form-footer">
                <div class="links">
                    <a href="/register">注册账号</a> |
                    <a href="/forgot">忘记密码?</a>
                </div>
            </div>
        </form>
    </div>

    <script>
        // 简单的表单验证
        document.querySelector('form').addEventListener('submit', function(e) {
            const username = document.querySelector('input[name="username"]').value.trim();
            const password = document.querySelector('input[name="password"]').value.trim();

            if (!username || !password) {
                e.preventDefault();
                alert('请填写用户名和密码！');
            }
        });
    </script>
</body>
</html>